package sg.edu.nus.iss.vmcs.util;

import sg.edu.nus.iss.vmcs.entity.Coin;
import sg.edu.nus.iss.vmcs.ui.CustomerPanel;

/**
 * This class will act as an adaptee.
 * @author user
 *
 */
public class BestCoinValidator {
	private Coin coin;
	
	public BestCoinValidator(Coin coin) {
		this.coin = coin;
	}
	
	public boolean isValid(Coin actualCoin) {
		boolean isValid = false;
		
		if (!((int)coin.getWeight()==0)) {
			if (checkHeadImage(actualCoin) && checkTailImage(actualCoin)) {
				if (checkRadius(actualCoin)) {
					if(checkWeight(actualCoin) && checkThickness(actualCoin)) {
						isValid = true;
					}
				}
			}
		}
		
		return isValid;
	}
	
	private boolean checkWeight(Coin actualCoin) {
		return coin.getWeight() == actualCoin.getWeight();
	}
	private boolean checkRadius(Coin actualCoin) {
		return coin.getRadius() == actualCoin.getRadius();
	}
	private boolean checkThickness(Coin actualCoin) {
		return coin.getThickness() == actualCoin.getThickness();
	}
	private boolean checkHeadImage(Coin actualCoin) {
		System.out.println("actualCoin: " + actualCoin + ", coin: " + coin);
		return coin.getHeadImg().equalsIgnoreCase(actualCoin.getHeadImg());
	}
	private boolean checkTailImage(Coin actualCoin) {
		return coin.getTailImg().equalsIgnoreCase(actualCoin.getTailImg());
	}	
	
}
